<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>支付表额度批次维护</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
        	<div class="FXBR">
        		<div class="fieldBox">
	                <div class="label">支付表号</div>
	                <div class="field">
	                    <input name="paySchCode" id="paySchCode"  type="text" class="ui-textbox"   ligerui="width: 160">
	                </div>
	            </div>
        		<div class="fieldBox">
	                <div class="label">融资机构名称</div>
	                <div class="field">
	                    <input name="insNm" id="insNm" type="text" class="ui-textbox" value="" ligerui="width: 160">
	                </div>
	            </div>
	            <div class="fieldBox">
	                <div class="label">项目名称</div>
	                <div class="field">
	                    <input name="fncPrjNm" id="fncPrjNm" type="text" class="ui-textbox" value="" ligerui="width: 160">
	                </div>
	            </div>
	            <div class="fieldBox">
	                <div class="label">起租日</div>
	               <div class="field">
		                        <input ligerui="width: 82" name="startTmB" id="startTmB" type="text" class="ui-datepicker" value="">
		                        -
		                        <input ligerui="width: 82" name="startTmE" id="startTmE" type="text" class="ui-datepicker" value="">
		           </div>
	            </div>
	            
            </div>
            
            <div class="clearFix"></div>
	            <div class="btnsBox formBtns notRight">
	               <span id="searchBtn" class="sq-button-round">查询</span>
	               <span id="clearBtn" class="sq-button-round">清空</span>
	                <span id="exportBtn" class="sq-button-round">导出</span>
	               <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
	            </div>
        	</div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid">
</div>

<script type="text/javascript">
	var grid = null;
	$("#clearBtn").click(function(event) {
	    $("#resetBtn").click();  //重置 input-text
	    var form = liger.get("searchBar");
	    form.setData({  //重置select等特殊表单
	        "paySchCode": "",
	        "insNm": "",
	        "fncPrjNm": "",
	        "startTmB": "",
	        "startTmE": ""
	    });
	});
	$(function () {
		initInstLstForm();
		initGrid();
	    initForm();
		initEvent();
	});
	function initForm(){
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    grid.options.isSingleCheck=true;	
		$("#searchBar").ligerForm();
	}
	
	function initEvent(){
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         console.log(JSON.stringify(data));
	         for (var name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	}
	
	function initGrid(){
		$("#ligergrid1").ligerGrid({
	    	url: '<%=path%>/rfbuss/fncpreabslimrec/initPayRList.do',
	    	method : 'get',
	        columns: [
	            { display: '支付表号', name: 'paySchCode', width: 150 , align:'center', enabledSort:true},
	    	    { display: '承租人名称', name: 'cstNm', width: 150, enabledSort:true },
	    	    { display: '融资机构', name: 'insNm', width: 150, enabledSort:true,
	    	    	render: function (rowdata, rowindex, value, column) { 
	    	    		var h='<a href="javascript:detailJG(';
	            		h+="'"+rowdata.insId+"'";
	                    h+=')">'+value+'</a>';
	                        return h;
	    	    	}	
	            },
	            { display: '再融资项目', name: 'fncPrjNm', width: 150 , enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            			if(value&&value!="null"){
	            		    h+='<a href="javascript:detailBtn(';
	                        h+="'"+rowdata.fncPrjId+"'";
	                        h+=')">'+value+'</a>'
	            			}
	                        return h;
						}
	            },
	            { display: '批次号', name: 'batNo', width: 150,enabledSort:true,
	            	render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            			if(value&&value!="null"){
	            		    h+='<a href="javascript:detailLim(';
	                        h+="'"+rowdata.limId+"'";
	                        h+=')">'+value+'</a>'
	            			}
	                        return h;
						}
	            },
	            { display: '起租日', name: 'startTm', width: 100 , render:renderDate, enabledSort:true},
	            { display: '创建时间', name: 'crtTm',width:100, render:renderDate, enabledSort:true},
	            
	        ],
	        pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            allowUnSelectRow: true,
            alternatingRow: false
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(200);	
	}
	function detailLim(id){
		
		$.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 400,
            height:320,
            title : '帐号批次信息详情',
            url:'<%=path%>/rfbuss/fncpreabslim/toAddPage.do?view=1&id='+id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
	   
	}
	function detailJG(id){
	    Add_navTab('tab_project_detail'+id,'机构信息详情','<%=path%>/rfbase/fribaseinfo/toDetailPage.do?id='+id);
	}
	function detailBtn(id){
			Add_navTab('tab_project_detail'+id,'项目基本信息详情','<%=path%>/rfbuss/fncprjbscinfo/toDetailPage1.do?id='+id);
	}

	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	function initInstLstForm(){
		$("#insId").ligerComboBox({ 
		        url:'<%=path%>/rfbase/fncprjpaysch/initInstList.do',
		        ajaxType :'GET', 
		        valueField: 'id', textField: 'fundRasInsNm',
				columns: [
	                { header: '机构编号', name: 'id', width: 140 }, 
	                { header: '机构名称', name: 'fundRasInsNm', width: 120 },
	            ], 
	            width: 200,
	            selectBoxWidth: 480, 
	            selectBoxHeight: 240
	        });
	}
	
	//导出
	$("#exportBtn").click(function(event) {
		var form = liger.get("searchBar");
		var data = form.getData();
		
		var url = '<%=path%>/rfbuss/fncpreabslimrec/exportExcel.do';
		$('#searchBar').attr('action', url);  
        $('#searchBar').submit();

	})

  	
</script>
</body>
</html>